class Task54:
    def __init__(self):
        self.index = -1

    def run(self, tree, k):
        self.index = -1
        if tree is None:
            return None
        return self.inorder(tree, k)

    def inorder(self, node, k):
        if node.left is not None:
            result = self.inorder(node.left, k)
            if result is not None:
                return result
        self.index += 1
        if self.index == k:
            return node.val
        if node.right is not None:
            return self.inorder(node.right, k)
